const { ipcMain } = require("electron")
const store = require("../electronStore/index")
const { fileSavePath } = require("./downLoad/fileUtils")
function setting(win) {
  /**
   * 设置配置项
   * @param {Object} params
   */
  ipcMain.handle("setConfig", (event, params) => {
    store.set("configOption", JSON.parse(params))
    return true
  })
  // 获取配置项
  ipcMain.handle("getConfig", () => store.get("configOption"))
  /**
   * 设置下载位置
   */
  ipcMain.handle("setDownloadPath", async () => {
    const dialogPath = await fileSavePath(win)
    return dialogPath
  })
}
module.exports = {
  setting
}
